<extend name="Public:base" />

<block name="content">

    <form action="{:U('Activity/index')}" method="post">
        <div class="table-responsive">
            <table class="table table-striped table-bordered table-hover search-form"  id="nav-table">
                <thead>
                <th><input name="search" type="text" placeholder="输入查找标题" value="{$search?$search:''}" />
                    <!--  <a class="btn btn-primary" href="javascript:;" id="search" url="{:U('Member/index')}">搜索</a>-->
                    <input type="submit" value="搜索" class="btn btn-primary btn-sm radius5">
                </th>
                </thead>
            </table>
        </div>
    </form>
    <div class="table-responsive">
        <form action="{:U('Activity/delete')}" method="post" id="formData">
            <div style="padding-bottom: 8px;">
                <a style="{$update==1?'':'display: none'}"  class="btn btn-primary btn-sm radius5" href="{:U('Activity/add')}">添加</a>
                <input  style="{$delete==1?'':'display: none'}"  class="btn btn-primary btn-sm radius5" id="delete" value="删除" type="submit">
            </div>
            <table class="table table-striped table-bordered table-hover" id="mytable">

                <thead>
                <tr>
                    <th class="center" style="width: 30px;"><input name="Fruit" id="CheckAll" type="checkbox" value="" /><!-- <label for="all">全选</label> --></th>
                    <th style="width: 46px">序号</th>
                    <th> 标题</th>
                    <th>内容</th>
                    <th class="col-xs-1">添加用户</th>
                    <th>添加时间</th>
                </tr>
                </thead>
                <tbody>
                <volist name="notice" id="ba" key="k">
                    <tr>
                        <td class="center"><input class="che" name="ids[]" type="checkbox" value="{$ba.id}" /></td>
                        <td>{$k}</td>
                        <td>{$ba.title}</td>
                        <td>{$ba.content|html_entity_decode}</td>
                        <td>{$ba.create_user}</td>
                        <td>{$ba['create_time']|date="Y-m-d H:i:s",###}</td>
                        <!--<td><a href="{:U('Activity/edit').'&id='.$ba['id']}" class="btn btn-xs btn-info radius5">
                            <i class="ace-icon fa">编辑</i></a></td>-->

                    </tr>
                </volist>
                <tr>
                    <td colspan="20" class="page">{$page}</td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</block>
<block name="javascript">
    <script>
        var le=0;
        $(function(){
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input,select').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });

            $("#CheckAll").click(function() {
                console.log(this.checked)
                $(".che").attr("checked",this.checked);
            })
        });
        $('#delete').click(function(){
            for(var i=0;i<$('.che').length;i++){
                if($('.che')[i].checked==true){
                    le+=1;
                }
            }
            if(le==0){
                $.jbox.info('选择不能为空', 'jBox');
                return false;
            }
            $('#formData').ajaxSubmit(function(data){
                $.jbox.info("删除成功！", 'loading');
                window.setTimeout(function () {window.location.href="{:U('Activity/index')}"; }, 500);
            })
            return false;
        })

    </script>
</block>